package com.yf1706.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;

import com.yf1706.bean.EducationSetting;
import com.yf1706.bean.HealthSetting;
import com.yf1706.bean.NationSetting;
import com.yf1706.bean.PoliticalSetting;
import com.yf1706.bean.PostSetting;
import com.yf1706.bean.RankSetting;
import com.yf1706.bean.RelationshipSetting;
import com.yf1706.bean.SexSetting;
import com.yf1706.bean.SkillLevelSetting;
import com.yf1706.bean.SkillSetting;
import com.yf1706.dao.jpa.IEducationSettingJDAO;
import com.yf1706.dao.jpa.IHealthSettingJDAO;
import com.yf1706.dao.jpa.INationSettingJDAO;
import com.yf1706.dao.jpa.IPoliticalSettingJDAO;
import com.yf1706.dao.jpa.IRelationshipSettingJDAO;
import com.yf1706.dao.jpa.ISexSettingJDAO;
import com.yf1706.dao.jpa.ISkillLevelSettingJDAO;
import com.yf1706.dao.jpa.ISkillSettingJDAO;
import com.yf1706.dao.mybatis.IPostSettingJDAO;
import com.yf1706.dao.mybatis.IRankSettingJDAO;

@Service
@Transactional(rollbackFor=Exception.class)
public class SettingService {
	@Autowired
	private IPostSettingJDAO psjdao;
	@Autowired
	private IRankSettingJDAO rsjdao;
	@Autowired
	private ISexSettingJDAO ssjdao;
	@Autowired
	private IEducationSettingJDAO esjdao;
	@Autowired
	private IPoliticalSettingJDAO polsjdao;
	@Autowired
	private IHealthSettingJDAO hsjdao;
	@Autowired
	private INationSettingJDAO nsjdao;
	@Autowired
	private IRelationshipSettingJDAO rlsjdao;
	@Autowired
	private ISkillSettingJDAO sksjdao;
	@Autowired
	private ISkillLevelSettingJDAO sklsjdao;
	
	//职务
	public List<PostSetting> findAllPostSettingByIfDisabled() {
		return psjdao.findByIfDisabled((byte) 0);
	}
	
	public List<PostSetting> findAllPostSetting() {
		return (List<PostSetting>) psjdao.findAll();
	}
	
	public PostSetting findPostSettingByPostId(int postId) {
		return psjdao.findByPostId(postId);
	}

	public PostSetting findPostSettingByPostName(String postName) {
		return psjdao.findByPostName(postName);
	}
	//职级
	public List<RankSetting> findAllRankSettingByIfDisabled() {
		return rsjdao.findByIfDisabled((byte) 0);
	}
	
	public List<RankSetting> findAllRankSetting() {
		return (List<RankSetting>) rsjdao.findAll();
	}
	
	public RankSetting findRanktSettingByRankId(int rankId) {
		return rsjdao.findByRankId(rankId);
	}

	public RankSetting findRanktSettingByRankName(String rankName) {
		return rsjdao.findByRankName(rankName);
	}
	
	//性别
	public List<SexSetting> findAllSexByIfDisabled(byte ifDisabled) {
		return ssjdao.findByIfDisabled(ifDisabled);
	}
	public SexSetting findSexBySexId(byte sexId) {
		return ssjdao.findBySexId(sexId);
	}
	
	public List<EducationSetting> findAllEducationByIfDisabled(byte ifDisabled) {
		return esjdao.findByIfDisabled(ifDisabled);
	}
	public EducationSetting findEducationByEducationId(byte educationId) {
		return esjdao.findByEducationId(educationId);
	}
	
	public List<PoliticalSetting> findAllPoliticalSettingByIfDisabled(byte ifDisabled) {
		return polsjdao.findByIfDisabled(ifDisabled);
	}
	public PoliticalSetting findPoliticalByPoliticalId(byte politicalId) {
		return polsjdao.findByPoliticalId(politicalId);
	}
	
	public List<HealthSetting> findAllHealthSettingByIfDisabled(byte ifDisabled) {
		return hsjdao.findByIfDisabled(ifDisabled);
	}
	public HealthSetting findHealthByHealthId(byte healthId) {
		return hsjdao.findByHealthId(healthId);
	}
	
	public List<NationSetting> findAllNationSettingByIfDisabled(byte ifDisabled) {
		return nsjdao.findByIfDisabled(ifDisabled);
	}
	public NationSetting findNationByNationId(byte nationId) {
		return nsjdao.findByNationId(nationId);
	}
	public List<SkillSetting> findAllSkillSettingByIfDisabled(byte ifDisabled) {
		return sksjdao.findByIfDisabled(ifDisabled);
	}
	public SkillSetting findSkillBySkillId(byte skillId) {
		return sksjdao.findBySkillId(skillId);
	}
	public List<SkillLevelSetting> findAllSkillLevelSettingByIfDisabled(byte ifDisabled) {
		return sklsjdao.findByIfDisabled(ifDisabled);
	}
	public SkillLevelSetting findSkillLevelBySkilLevellId(byte skillLevelId) {
		return sklsjdao.findBySkillLevelId(skillLevelId);
	}
	//获取所有关系设定对象集合
	public List<RelationshipSetting> findAllRelationshipSettingByIfDisabled(byte ifDisabled){
		return rlsjdao.findByIfDisabled(ifDisabled);
	}
	//根据id获取关系设定对象
	public RelationshipSetting findRelationshipSettingById(byte relationshipId){
		return rlsjdao.findByRelationshipId(relationshipId);
	}
}
